package com.chen.spring.cloud.service.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chen.entity.Goods;
import com.chen.entity.IndexLink;
import com.chen.spring.cloud.service.admin.mapper.GoodsMapper;
import com.chen.spring.cloud.service.admin.mapper.IndexLinkMapper;
import com.chen.spring.cloud.service.admin.service.IIndexLinkService;
import com.chen.vo.YuYueVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 首页快捷链接设置表 服务实现类
 * </p>
 *
 * @author 陈永鹏
 * @since 2019-03-26
 */
@Service
public class IndexLinkServiceImpl extends ServiceImpl<IndexLinkMapper, IndexLink> implements IIndexLinkService {

    @Autowired
    private IndexLinkMapper indexLinkMapper;

    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public YuYueVo getYuyue() {
        YuYueVo yuYueVo = new YuYueVo();
        IndexLink indexLink = indexLinkMapper.selectOne(null);
        int good_id = indexLink.getYy_goods_id();
        Goods goods = goodsMapper.selectOne(new QueryWrapper<Goods>().eq("goods_id",good_id));
        if (goods == null){
            return yuYueVo;
        } else {
            yuYueVo.setGoods_title(goods.getGoods_title());
            yuYueVo.setYy_goods_id(good_id);
            yuYueVo.setYy_title(indexLink.getYy_title());
        }

        return yuYueVo;
    }
}
